package snapex.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import snapex.core.mapper.UserMapper;
import snapex.core.model.User;
import snapex.user.service.IUserService;

@Service
public class UserService implements IUserService {

	@Autowired
	private UserMapper userMapper;
	
	@Override
	public User getByUsername(String username) throws UsernameNotFoundException {
		
		User user = userMapper.selectByPrimaryKey(username);
		if(user == null) {			
			throw new UsernameNotFoundException(username);
		}
		
		return user;
	}
}
